﻿/*******************************************************************************
 * Copyright @ 2017 YunSpace.Framework 版权所有
 * Author: GaoTang
 * Description: YunSpace 快速开发平台
 * Website：http://www.yunspace.com.cn
*********************************************************************************/
#region USING SYSTEM
using YunSpace.Core;
using YunSpace.Domain.Entity.OrderFlowManage;
using YunSpace.Domain.IRepository.OrderFlowManage;
using YunSpace.Repository.OrderFlowManage;
using System.Collections.Generic;
using System.Linq;
#endregion

namespace YunSpace.Application.OrderFlowManage
{
    public class ClientOrderimpressApp
    {
        private IClientOrderimpressRepository service = new ClientOrderimpressRepository();

        public List<ClientOrderimpressEntity> GetList(Pagination pagination, string queryJson)
        {
            var expression = ExtLinq.True<ClientOrderimpressEntity>();
            var queryParam = queryJson.ToJObject();
            // if (!queryParam["keyword"].IsEmpty())
            // {
            //     string keyword = queryParam["keyword"].ToString();
            //     expression = expression.And(t => t.F_Account.Contains(keyword));
            // }
            // if (!queryParam["timeType"].IsEmpty())
            // {
            //     string timeType = queryParam["timeType"].ToString();
            //     DateTime startTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate();
            //     DateTime endTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate().AddDays(1);
            //     switch (timeType)
            //     {
            //         case "1":
            //             break;
            //         case "2":
            //             startTime = DateTime.Now.AddDays(-7);
            //             break;
            //         case "3":
            //             startTime = DateTime.Now.AddMonths(-1);
            //             break;
            //         case "4":
            //             startTime = DateTime.Now.AddMonths(-3);
            //             break;
            //         default:
            //             break;
            //     }
            //     expression = expression.And(t => t.F_Date >= startTime && t.F_Date <= endTime);
            // }
            return service.FindList(expression, pagination);
        }

        public ClientOrderimpressEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }
        public void DeleteForm(string keyValue)
        {
            service.Delete(t => t.F_Id == keyValue);
        }
        public void SubmitForm(ClientOrderimpressEntity clientOrderimpressEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                clientOrderimpressEntity.Modify(keyValue);
                service.Update(clientOrderimpressEntity);
            }
            else
            {
                clientOrderimpressEntity.Create();
                // clientOrderimpressEntity.F_Category = 2;
                service.Insert(clientOrderimpressEntity);
            }
        }
    }
}

